<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" method="post" action="<?php echo site_url(X_URL.'variable/update');?>">
                            <input name="varname" type="hidden" value="<?php if(isset($var)){ echo $var["k"];}?>">
                            <?php echo csrf_hidden();?>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 变量说明 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" id="name" placeholder="变量说明"
                                           class="col-xs-10 col-sm-5" value="<?php if(isset($var)){ echo $var["name"];}?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 变量名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="k" id="k" placeholder="变量名称" class="col-xs-10 col-sm-5"
                                           value="<?php if(isset($var)){ echo $var['k'];}?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 变量类型 </label>
                                <div class="col-sm-9">
                                    <div class="radio">
                                        <label class="col-md-2 col-xs-6 col-sm-4">
                                            <input name="type" type="radio" class="ace variableCheck" value="1" checked >
                                            <span class="lbl"> 字符串</span>
                                        </label>
                                        <label class="col-md-2 col-xs-6 col-sm-4">
                                            <input name="type" type="radio" class="ace variableCheck" value="2" >
                                            <span class="lbl"> 文本</span>
                                        </label>
                                        <span class="help-block col-sm-reset inline hidden-480">若选择文本类型，则需要去网站配置页面设置此变量</span>
                                    </div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group variableValue">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 变量值 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="v" id="v" placeholder="变量值" class="col-xs-10 col-sm-5"
                                           value="<?php if(isset($var)){ echo $var['v'];}?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 排序 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="ord" id="ord" placeholder="排序" class="col-xs-10 col-sm-5"
                                           value="<?php if(isset($var)){ echo $var['ord'];}else{echo '0';}?>">
                                </div>
                            </div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    </div><?php $this->load->view('common/footer');?>



<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".btn-info.submit").click(function () {
            var webname = $("#webname").val();
            var url = $("#url").val();
            if (webname == 0) {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "标题必须选择。",
                    buttons: {
                        "success":{
                            "label": "确定",
                            "className": "btn-danger"
                         }
                    }
                });
                return;
            }
            if (url == '') {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "链接地址必须填写。",
                    buttons:{
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                         }
                    }
                });
                return;
            }
            $("#form").submit();
    });
    });
    $(".variableCheck").click(function () {
        var val = $(this).val();
        if(val == 2){
            $(".variableValue").hide();
        }else{
            $(".variableValue").show();
        }
    });
</script>
</body>
</html>
